package com.gongpingjialoan.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.gongpingjialoan.R;
import com.gongpingjialoan.activity.car.PushSettingActivity;
import com.gongpingjialoan.widget.adapters.ArrayWheelAdapter;
import com.gongpingjialoan.widget.views.WheelView;

/**
 * Created by Administrator on 2016/6/21.
 */
public class PushTimeDialog extends Dialog {

    private Context mContext;

    private Button mButton;

    private WheelView timeWheelView1, timeWheelView2;

    private ArrayWheelAdapter<String> timeWheelAdapter1 , timeWheelAdapter2;

    private PushSettingActivity mPushSettingActivity;

    private String[] times = {"00:00", "01:00", "02:00", "03:00", "04:00", "05:00", "06:00", "07:00", "08:00", "09:00","10:00","11:00", "12:00", "13:00",
            "14:00" ,"15:00" ,"16:00" ,"17:00" ,"18:00" ,"19:00" ,"20:00", "21:00" ,"22:00" ,"23:00", "24:00"};

    public PushTimeDialog(Context context) {
        super(context, R.style.dialogs);
        this.mContext = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.push_time_dialog);
        timeWheelView1 = (WheelView) findViewById(R.id.time1);
        timeWheelView2 = (WheelView) findViewById(R.id.time2);
        mButton = (Button) findViewById(R.id.sure_button);
        timeWheelView1.setVisibleItems(3);
        timeWheelView1.setCyclic(true);
        timeWheelAdapter1 = new ArrayWheelAdapter<String>(mContext, times);
        timeWheelAdapter1.setItemResource(R.layout.time_tiem);
        timeWheelAdapter1.setItemTextResource(R.id.text);
        timeWheelView1.setViewAdapter(timeWheelAdapter1);
        timeWheelView1.setCurrentItem(2);

        timeWheelView2.setVisibleItems(3);
        timeWheelView2.setCyclic(true);
        timeWheelAdapter2 = new ArrayWheelAdapter<String>(mContext, times);
        timeWheelAdapter2.setItemResource(R.layout.time_tiem);
        timeWheelAdapter2.setItemTextResource(R.id.text);
        timeWheelView2.setViewAdapter(timeWheelAdapter2);
        timeWheelView2.setCurrentItem(2);


        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                mPushSettingActivity = (PushSettingActivity) mContext;
//                mPushSettingActivity.setTime(times[timeWheelView1.getCurrentItem()] , times[timeWheelView2.getCurrentItem()]);
//                dismiss();
            }
        });

    }
}
